package com.tanguy.user.ui.hotel.activity

import android.support.v4.content.ContextCompat
import android.support.v7.widget.LinearLayoutManager
import android.view.Gravity
import android.view.View
import com.tanguy.user.R
import com.tanguy.user.base.ImmersionTitleActivity
import com.tanguy.user.ui.hotel.adapter.HotelAdapter
import com.tanguy.user.ui.me.activity.notice.NoticeActivity
import com.tanguy.user.utlis.extend.dp2px
import kotlinx.android.synthetic.main.activity_promotion.*
import org.jetbrains.anko.startActivity

/**
 * Created by dab on 2017/10/11 0011 18:13
 * 特价促销
 */
class PromotionActivity : ImmersionTitleActivity() {
    override fun setContentViewRes(): Int = R.layout.activity_promotion
    override fun initView() {
        super.initView()
        titleBar.titleView.apply {
            setBackgroundResource(R.drawable.corners_border_search)
            hint = "输入酒店名称搜索"
            isEnabled = true
            setPadding(dp2px(30), 0, 0, 0)
            compoundDrawablePadding = dp2px(18)
            gravity = Gravity.CENTER_VERTICAL
            setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(context, R.mipmap.ico_alipay), null, null, null)
            layoutParams.height = dp2px(30)
            layoutParams.width = dp2px(200)
        }
        titleBar.addRightButton(null, 0, View.OnClickListener {
            startActivity<NoticeActivity>()
        }).apply {
            setBackgroundResource(R.mipmap.ic_launcher)

        }
        rv_hotel.layoutManager = LinearLayoutManager(this)
        rv_hotel.adapter = HotelAdapter(arrayListOf(1, 2, 3, 4, 5)).also {
            it.itemClick = {
                _, _,_ ->
                startActivity<HotelDetailsActivity>()

            }

        }

    }
}